package com.heima.wemedia.controller.v1;

import com.heima.model.comment.pojos.CommentLikeDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.CommentListDto;
import com.heima.model.wemedia.dtos.WmCommentDto;
import com.heima.model.wemedia.dtos.WmRepayCommentDto;
import com.heima.model.wemedia.dtos.WmUpdateCommentDto;
import com.heima.wemedia.service.WmCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment/manage")
public class WmCommentController {
    @Autowired
    private WmCommentService wmCommentService;

    /**
     * 查询文章 是否可评论
     *
     * @param dto
     * @return
     */
    @PostMapping("/find_news_comments")
    public ResponseResult findNewsComments(@RequestBody WmCommentDto dto) {
        return wmCommentService.findNewsComments(dto);
    }

    /**
     * 打开或关闭评论
     *
     * @param dto
     * @return
     */
    @PostMapping("update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody WmUpdateCommentDto dto) {
        return wmCommentService.updateCommentStatus(dto);
    }

    /**
     * 评论详情
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult commentList(@RequestBody CommentListDto dto) {
        return wmCommentService.commentList(dto);
    }

    /**
     * 作者点赞评论
     *
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
       return wmCommentService.like(dto);
    }

    /**
     * 作者回复评论
     * @param dto
     * @return
     */
    @PostMapping("/comment_repay")
    public ResponseResult repay(@RequestBody WmRepayCommentDto dto){
        return wmCommentService.repay(dto);
    }
}
